home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 9866 / 9866.xpi / modules / rss / 70.jsm < prev    next >
Encoding:
Text File  |  2009-09-22  |  2.7 KB  |  105 lines

  1. Components.utils.import("resource://samfind/rss/samfind_modrssutils.jsm");
  2.  
  3. var EXPORTED_SYMBOLS = ["samfindRSSGetLink", "samfindRSSGetTitle", "samfindRSSGetDate", "samfindRSSGetImage", "samfindRSSGetContent"];
  4.  
  5. function samfindRSSGetLink(websiteRssUrl, item)
  6. {
  7.     return null;    
  8. }
  9.  
  10. function samfindRSSGetTitle(websiteRssUrl, item)
  11. {
  12.     return null;    
  13. }
  14.  
  15. function samfindRSSGetDate(websiteRssUrl, item)
  16. {
  17.     return null;
  18. }
  19.  
  20. function samfindRSSGetImage(websiteRssUrl, item)
  21. {
  22.     return null;
  23. }
  24.  
  25. function samfindRSSGetContent(websiteRssUrl, item, title, link)
  26. {
  27.     var content = (item.getElementsByTagName("content"))[0];
  28.     if (!content)
  29.     {
  30.         return null;
  31.     }
  32.     content = content.textContent;
  33.     content = content.replace(/&(lt|gt);/g, function(strMatch, p1){return (p1 == "lt") ? "<" : ">";});
  34.     content = content.replace(/<br>/, "<br/>");
  35.     content = content.replace(/.gif">/g, ".gif\"/>");
  36.     content = content.replace(/.jpg">/g, ".jpg\"/>");
  37.     var start = content.indexOf("<span>");
  38.     if (start == -1)
  39.     {
  40.         return null;    
  41.     }
  42.     start += 6;
  43.     var end  = content.indexOf("</span>", start);
  44.     var response = content.substring(start, end);
  45.     response = samfind_modrssutils.truncate(response, 12) + "<br/>";
  46.     response = samfind_modrssutils.removeRubbish(response);
  47.     start = content.indexOf("Views:</span>");
  48.     if (start != -1)
  49.     {
  50.         start += 13;
  51.         end = content.indexOf("</div>", start);
  52.         if (end != -1)
  53.         {
  54.             response += "<span class=\"left\">" + content.substring(start, end) + " views</span><br/>";
  55.         }
  56.     }
  57.     start = content.indexOf("Time:</span>");
  58.     if (start != -1)
  59.     {
  60.         start += 12;
  61.         end = content.indexOf("</span>", start);
  62.         if (end != -1)
  63.         {
  64.             response += content.substring(start, end).replace("style=\"color: #000000; font-size: 11px; font-weight: bold;\"", "") + "</span> ";
  65.         }
  66.     }
  67.     start = content.indexOf("From:</span>");
  68.     if (start != -1)
  69.     {
  70.         start += 12;
  71.         end = content.indexOf("</div>", start);
  72.         if (end != -1)
  73.         {
  74.             response += content.substring(start, end) + "<br/>";
  75.         }
  76.     }
  77.     start = content.indexOf("<img style=\"border: 0px none;");
  78.     while (start != -1)
  79.     {
  80.         end = content.indexOf(".gif\"/>", start);
  81.         if (end == -1)
  82.         {
  83.             break;    
  84.         }
  85.         else
  86.         {
  87.             end += 7;
  88.             response += content.substring(start, end);
  89.             start = content.indexOf("<img style=\"border: 0px none;", end);
  90.         }
  91.     }
  92.     response += "<br/>";
  93.     start = content.indexOf("More in</span>");
  94.     if (start != -1)
  95.     {
  96.         start += 14;
  97.         end = content.indexOf("</td>", start);
  98.         if (end != -1)
  99.         {
  100.             response += "<span class=\"left\">More in:</span> " + content.substring(start, end).replace("categories_portal", "browse");
  101.         }
  102.     }
  103.     response = samfind_modrssutils.HTML2Unicode(response);
  104.     return response;
  105. }